package com.kxf.androidtestdemo.service;

import android.app.Service;
import android.content.Intent;
import android.os.Environment;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;

import com.kxf.androidtestdemo.activity.RemoteServiceActivity;

/**
 * @ProjectName: AndroidTestDemo
 * @Package: com.kxf.androidtestdemo.service
 * @ClassName: MyRemoteService
 * @Description: java类作用描述
 * @Author: kuangxuefeng
 * @qq: 1024883177
 * @CreateDate: 2020/6/22 10:24
 */
public class MyRemoteService extends Service {
    private static boolean re = isExistSDCard();
    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        isExistSDCard();
        Intent intent1 = new Intent(this, RemoteServiceActivity.class);
        intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent1);
        return super.onStartCommand(intent, flags, startId);
    }

    private static boolean isExistSDCard() {
        Log.d("MyRemoteService", "Environment.getExternalStorageState()=" + Environment.getExternalStorageState());
        Log.d("MyRemoteService", "Environment.MEDIA_MOUNTED=" + Environment.MEDIA_MOUNTED);
        return Environment.getExternalStorageState().equals(
                Environment.MEDIA_MOUNTED);
    }
}
